package com.xiaoshuidi.cloud.module.contract.controller.app.bill;

import com.xiaoshuidi.cloud.framework.common.exception.ServiceException;
import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.contract.controller.app.bill.vo.OrderFeesDetailAppVo;
import com.xiaoshuidi.cloud.module.contract.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.contract.service.bill.OrderFeesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.error;
import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 账单")
@RestController
@RequestMapping(ApiConstants.NAME + "/app" )
@Validated
@Slf4j
public class AppOrderFeesController {

    @Resource
    private OrderFeesService orderFeesService;


    @GetMapping("/get-order-fees")
    @Operation(summary = "通过账单id 获得账单明细列表")
    @Parameter(name = "orderId", description = "账单id", required = true, example = "7422")
    public CommonResult<OrderFeesDetailAppVo> orderDetail(@RequestParam("id") Long id) {
        try {
            OrderFeesDetailAppVo billDetails = orderFeesService.getOrderFeeDetailApp(id);
            return success(billDetails);
        } catch (ServiceException e) {
            return error(e.getCode(),e.getMessage());
        }
    }

}
